package com.project.estate.commons.handler;

import com.project.estate.commons.config.JsonResult;
import com.project.estate.commons.config.ResultTool;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class MyException {

    @ExceptionHandler(CarAddException.class)
    public JsonResult userSaveException(Throwable e) {
        return ResultTool.fail(510, e.getMessage());
    }

    @ExceptionHandler(ActivityAddException.class)
    public JsonResult activityAddException(Throwable e) {
        return ResultTool.fail(511, e.getMessage());
    }

    @ExceptionHandler(BuildingAddException.class)
    public JsonResult buildingAddException(Throwable e) {
        return ResultTool.fail(512, e.getMessage());
    }

    @ExceptionHandler(ChangerDetailAddException.class)
    public JsonResult changerDetailAddException(Throwable e) {
        return ResultTool.fail(513, e.getMessage());
    }

    @ExceptionHandler(ChargeItemAddException.class)
    public JsonResult chargeItemAddException(Throwable e) {
        return ResultTool.fail(514, e.getMessage());
    }

    @ExceptionHandler(ChargeItemUpdateException.class)
    public JsonResult ChargeItemUpdateException(Throwable e) {
        return ResultTool.fail(515, e.getMessage());
    }

    @ExceptionHandler(ChargeItemDeleteException.class)
    public JsonResult ChargeItemDeleteException(Throwable e) {
        return ResultTool.fail(516, e.getMessage());
    }

    @ExceptionHandler(ChargeItemFindException.class)
    public JsonResult ChargeItemFindException(Throwable e) {
        return ResultTool.fail(517, e.getMessage());
    }

    @ExceptionHandler(CommunityAddException.class)
    public JsonResult communityAddException(Throwable e) {
        return ResultTool.fail(518, e.getMessage());
    }

    @ExceptionHandler(CommunityDeleteException.class)
    public JsonResult communityDeleteException(Throwable e) {
        return ResultTool.fail(519, e.getMessage());
    }


    @ExceptionHandler(CommunityUpdateException.class)
    public JsonResult communityUpdateException(Throwable e) {
        return ResultTool.fail(520, e.getMessage());
    }


    @ExceptionHandler(CommunityFindException.class)
    public JsonResult communityFindException(Throwable e) {
        return ResultTool.fail(521, e.getMessage());
    }


    @ExceptionHandler(CarFindException.class)
    public JsonResult carFindException(Throwable e) {
        return ResultTool.fail(522, e.getMessage());
    }


    @ExceptionHandler(CarDeleteException.class)
    public JsonResult carDeleteException(Throwable e) {
        return ResultTool.fail(524, e.getMessage());
    }


    @ExceptionHandler(CarUpdateException.class)
    public JsonResult carUpdateException(Throwable e) {
        return ResultTool.fail(525, e.getMessage());
    }


    @ExceptionHandler(BuildingDeleteException.class)
    public JsonResult BuildingDeleteException(Throwable e) {
        return ResultTool.fail(526, e.getMessage());
    }


    @ExceptionHandler(BuildingFindException.class)
    public JsonResult buildingFindException(Throwable e) {
        return ResultTool.fail(527, e.getMessage());
    }


    @ExceptionHandler(ActivityFindException.class)
    public JsonResult activityFindException(Throwable e) {
        return ResultTool.fail(529, e.getMessage());
    }


    @ExceptionHandler(ActivityDeleteException.class)
    public JsonResult activityDeleteException(Throwable e) {
        return ResultTool.fail(530, e.getMessage());
    }


    @ExceptionHandler(ActivityUpdateException.class)
    public JsonResult activityUpdateException(Throwable e) {
        return ResultTool.fail(531, e.getMessage());
    }





}
